package my.jwds.p693;

public class HasAlternatingBits {

    public static void main(String[] args) {

        HasAlternatingBits obj = new HasAlternatingBits();
        long start = System.currentTimeMillis();
        System.out.println(obj.hasAlternatingBits(5));
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }



    public boolean hasAlternatingBits(int n) {
        n = n ^ (n>>1);
        return (n & (n+1)) == 0;
    }
}